<?php

namespace app\h5api\validate;

use think\Validate;

class Address extends Validate
{
	protected $scene = [
        'Linkage' => ['code'],
        'EditAddress' => ['name','phone','province_id','city_id','area_id','province_name','city_name','area_name','detail','is_default'],
	];

	protected $rule =   [
        'code'  => 'require|number',
        'address_id' => 'require|number',
        'name' => 'require',
        'phone' => 'require|mobile',
        'province_id' => 'require|number',
        'city_id' => 'require|number',
        'area_id' => 'require|number',
        'province_name' => 'require|chs',
        'city_name' => 'require|chs',
        'area_name' => 'require|chs',
        'detail' => 'require|chsAlphaNum',
        'is_default' => 'require|in:0,1',
	];

	protected $message  =   [
		'code.require' => '请填写地址编码',
		'code.number'     => '请填写正确的地址编码',
        'name.require' => '请填写收货人姓名',
        'phone.require' => '请填写手机号',
        'phone.mobile'     => '手机号有误',
		'province_id.require' => '缺少省级编码',
		'province_id.number'     => '请填写正确的省级编码',
		'city_id.require' => '缺少市级编码',
		'city_id.number'     => '请填写正确的市级编码',
		'area_id.require' => '缺少区级编码',
		'area_id.number'     => '请填写正确的区级编码',
        'detail.require' => '请填写详细地址',
		'detail.chsAlphaNum'     => '地址详情只能是汉字、字母和数字',
        'is_default.require' => '是否默认',
		'is_default.in:0,1'     => '默认状态有误',
	];
}
